Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial tags and signature support #3

Merged
merged 2 commits into from
Apr 7, 2024
Merged

Initial tags and signature support #3

merged 2 commits into from
Apr 7, 2024

Conversation

jb55
Copy link
Contributor

@jb55 jb55 commented Apr 7, 2024

No description provided.

jb55 added 2 commits April 7, 2024 13:09
This commit adds support for iterating over note tags and tag elements.
This is zero-copy and heavily leverages rust lifetimes to ensure we
always have access within a transaction and note reference.

New types
=========

NdbStr - ndb note strings, offsets into the note string table
NdbStrVariant - ndb note string variants. can be 32-byte values or strings
Tag - A tag ["e", "abcdef..."]
Tags - Note tags [["hi", "3"], ["proxy", "..."]]
TagIter - An iterator over tag elements, producing NdbStr's
TagsIter - An iterator over tags elements, producing Tag's

Usage
=====

for tag in note.tags().iter() {
    for nstr in tag.iter() {
        match nstr.variant() {
	    NdbStrVariant::Str(s) => // string
	    NdbStrVariant::Id(s) =>  // 32-byte id
	}
    }
}

Changelog-Added: Add tags and tag iterators to Note
Fixes: #2
Cc: [email protected]
Signed-off-by: William Casarin <[email protected]>
@jb55 jb55 merged commit 87bf139 into master Apr 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant